# coding=utf-8
import arcpy
import os
import pandas as pd
import F

arcpy.env.overwriteOutput = True
path = r'D:\WorkData\20241119日达沟\资料\生公里桩'
zx = F.listFile(path, '中线'.decode('utf-8'), 'x')
KpList = []
arcpy.env.overwriteOutput = True
FidList = []
with arcpy.da.SearchCursor(zx, 'SHAPE@') as yb2:
    for row in yb2:
        lenth = row[0].length
        print lenth
        i = 0
        while i < lenth:
            name = 'K' + str(i / 1000)
            Kp = row[0].positionAlongLine(i)
            cn = [name, Kp]
            KpList.append(cn)
            print 'K' + str(i / 1000), row[0].positionAlongLine(i).centroid.X, row[0].positionAlongLine(
                i).centroid.Y
            i += 1000
p = arcpy.CreateFeatureclass_management(path, '公里桩', 'POINT',
                                        spatial_reference="4542")
arcpy.AddField_management(p, '里程', 'TEXT')
yb = arcpy.da.InsertCursor(p, ['里程', 'SHAPE@'])
for cn in KpList:
    yb.insertRow(cn)
del yb
